ERROR=-1
ERR=ERROR
OK=0
KEY_CODE_YES = 256
KEY_BREAK = 257
KEY_DOWN = 258
KEY_UP = 259
KEY_LEFT = 260
KEY_RIGHT = 261
KEY_HOME = 262
KEY_BACKSPACE = 263
KEY_F0 = 264
KEY_DL = 328
KEY_IL = 329
KEY_DC = 330
KEY_IC = 331
KEY_EIC = 332
KEY_CLEAR = 333
KEY_EOS = 334
KEY_EOL = 335
KEY_SF = 336
KEY_SR = 337
KEY_NPAGE = 338
KEY_PPAGE = 339
KEY_STAB = 340
KEY_CTAB = 341
KEY_CATAB = 342
KEY_ENTER = 343
KEY_SRESET = 344
KEY_RESET = 345
KEY_PRINT = 346
KEY_LL = 347
KEY_ABORT = 348
KEY_SHELP = 349
KEY_LHELP = 350
KEY_BTAB = 351
KEY_BEG = 352
KEY_CANCEL = 353
KEY_CLOSE = 354
KEY_COMMAND = 355
KEY_COPY = 356
KEY_CREATE = 357
KEY_END = 358
KEY_EXIT = 359
KEY_FIND = 360
KEY_HELP = 361
KEY_MARK = 362
KEY_MESSAGE = 363
KEY_MOVE = 364
KEY_NEXT = 365
KEY_OPEN = 366
KEY_OPTIONS = 367
KEY_PREVIOUS = 368
KEY_REDO = 369
KEY_REFERENCE = 370
KEY_REFRESH = 371
KEY_REPLACE = 372
KEY_RESTART = 373
KEY_RESUME = 374
KEY_SAVE = 375
KEY_SBEG = 376
KEY_SCANCEL = 377
KEY_SCOMMAND = 378
KEY_SCOPY = 379
KEY_SCREATE = 380
KEY_SDC = 381
KEY_SDL = 382
KEY_SELECT = 383
KEY_SEND = 384
KEY_SEOL = 385
KEY_SEXIT = 386
KEY_SFIND = 387
KEY_SHOME = 388
KEY_SIC = 389
KEY_SLEFT = 391
KEY_SMESSAGE = 392
KEY_SMOVE = 393
KEY_SNEXT = 394
KEY_SOPTIONS = 395
KEY_SPREVIOUS = 396
KEY_SPRINT = 397
KEY_SREDO = 398
KEY_SREPLACE = 399
KEY_SRIGHT = 400
KEY_SRSUME = 401
KEY_SSAVE = 402
KEY_SSUSPEND = 403
KEY_SUNDO = 404
KEY_SUSPEND = 405
KEY_UNDO = 406
ALT_0 = 407
ALT_1 = 408
ALT_2 = 409
ALT_3 = 410
ALT_4 = 411
ALT_5 = 412
ALT_6 = 413
ALT_7 = 414
ALT_8 = 415
ALT_9 = 416
ALT_A = 417
ALT_B = 418
ALT_C = 419
ALT_D = 420
ALT_E = 421
ALT_F = 422
ALT_G = 423
ALT_H = 424
ALT_I = 425
ALT_J = 426
ALT_K = 427
ALT_L = 428
ALT_M = 429
ALT_N = 430
ALT_O = 431
ALT_P = 432
ALT_Q = 433
ALT_R = 434
ALT_S = 435
ALT_T = 436
ALT_U = 437
ALT_V = 438
ALT_W = 439
ALT_X = 440
ALT_Y = 441
ALT_Z = 442
CTL_LEFT = 443
CTL_RIGHT = 444
CTL_PGUP = 445
CTL_PGDN = 446
CTL_HOME = 447
CTL_END = 448
KEY_A1 = 449
KEY_A2 = 450
KEY_A3 = 451
KEY_B1 = 452
KEY_B2 = 453
KEY_B3 = 454
KEY_C1 = 455
KEY_C2 = 456
KEY_C3 = 457
PADSLASH = 458
PADENTER = 459
CTL_PADENTER = 460
ALT_PADENTER = 461
PADSTOP = 462
PADSTAR = 463
PADMINUS = 464
PADPLUS = 465
CTL_PADSTOP = 466
CTL_PADCENTER = 467
CTL_PADPLUS = 468
CTL_PADMINUS = 469
CTL_PADSLASH = 470
CTL_PADSTAR = 471
ALT_PADPLUS = 472
ALT_PADMINUS = 473
ALT_PADSLASH = 474
ALT_PADSTAR = 475
ALT_PADSTOP = 476
CTL_INS = 477
ALT_DEL = 478
ALT_INS = 479
CTL_UP = 480
CTL_DOWN = 481
CTL_TAB = 482
ALT_TAB = 483
ALT_MINUS = 484
ALT_EQUAL = 485
ALT_HOME = 486
ALT_PGUP = 487
ALT_PGDN = 488
ALT_END = 489
ALT_UP = 490
ALT_DOWN = 491
ALT_RIGHT = 492
ALT_LEFT = 493
ALT_ENTER = 494
ALT_ESC = 495
ALT_BQUOTE = 496
ALT_LBRACKET = 497
ALT_RBRACKET = 498
ALT_SEMICOLON = 499
ALT_FQUOTE = 500
ALT_COMMA = 501
ALT_STOP = 502
ALT_FSLASH = 503
ALT_BKSP = 504
CTL_BKSP = 505
PAD0 = 506
CTL_PAD0 = 507
CTL_PAD1 = 508
CTL_PAD2 = 509
CTL_PAD3 = 510
CTL_PAD4 = 511
CTL_PAD5 = 512
CTL_PAD6 = 513
CTL_PAD7 = 514
CTL_PAD8 = 515
CTL_PAD9 = 516
ALT_PAD0 = 517
ALT_PAD1 = 518
ALT_PAD2 = 519
ALT_PAD3 = 520
ALT_PAD4 = 521
ALT_PAD5 = 522
ALT_PAD6 = 523
ALT_PAD7 = 524
ALT_PAD8 = 525
ALT_PAD9 = 526
CTL_DEL = 527
ALT_BSLASH = 528
CTL_ENTER = 529
SHF_PADENTER = 530
SHF_PADSLASH = 531
SHF_PADSTAR = 532
SHF_PADPLUS = 533
SHF_PADMINUS = 534
SHF_UP = 535
SHF_DOWN = 536
SHF_IC = 537
SHF_DC = 538
KEY_MOUSE = 539
KEY_SHIFT_L = 540
KEY_SHIFT_R = 541
KEY_CONTROL_L = 542
KEY_CONTROL_R = 543
KEY_ALT_L = 544
KEY_ALT_R = 545
KEY_RESIZE = 546
KEY_SUP = 547
KEY_SDOWN = 548
KEY_F=lambda n:KEY_F0+n

# Style Constants

A_NORMAL = (0)
A_ALTCHARSET = (0x00010000)
A_RIGHTLINE = (0x00020000)
A_LEFTLINE = (0x00040000)
A_INVIS = (0x00080000)
A_UNDERLINE = (0x00100000)
A_REVERSE = (0x00200000)
A_BLINK = (0x00400000)
A_BOLD = (0x00800000)

A_ATTRIBUTES = (0xffff0000)
A_CHARTEXT = (0x0000ffff)
A_COLOR = (0xff000000)

A_ITALIC = A_INVIS
A_PROTECT = ((0x00100000 | 0x00040000 | 0x00020000))

PDC_ATTR_SHIFT = (19)
PDC_COLOR_SHIFT = (24)

COLOR_RED = (1)
COLOR_GREEN = (2)
COLOR_BLUE = (4)
COLOR_CYAN = ((COLOR_BLUE | COLOR_GREEN))
COLOR_MAGENTA=((COLOR_RED | COLOR_BLUE))
COLOR_YELLOW =((COLOR_RED | COLOR_GREEN))

COLOR_WHITE = (7)

#ACS Constants
def ACS_PICK(w, n):
    return  ord(w) | A_ALTCHARSET
ACS_ULCORNER=ACS_PICK('l', '+')
ACS_LLCORNER=ACS_PICK('m', '+')
ACS_URCORNER=ACS_PICK('k', '+')
ACS_LRCORNER=ACS_PICK('j', '+')
ACS_RTEE=ACS_PICK('u', '+')
ACS_LTEE=ACS_PICK('t', '+')
ACS_BTEE=ACS_PICK('v', '+')
ACS_TTEE=ACS_PICK('w', '+')
ACS_HLINE=ACS_PICK('q', '-')
ACS_VLINE=ACS_PICK('x', '|')
ACS_PLUS=ACS_PICK('n', '+')